package io.renren.modules.book.controller;

import io.renren.common.utils.ExcelUtils;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.book.entity.BookEntity;
import io.renren.modules.book.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("book")
@CrossOrigin
public class BookController {
    @Autowired
    BookService bookService;
    @GetMapping("query")
    public R query(@RequestParam Map<String, Object> params){
        PageUtils list = bookService.queryList(params);
        return R.ok().put("list",list);
    }

    @PostMapping("upload")
    public R query(@RequestParam("file") MultipartFile file) throws Exception {
        String[] coo = {"title"};
        List<Map<String, Object>> list = ExcelUtils.leading(file, coo);
        return R.ok().put("list",list);
    }
}
